import {reqDetailInfo} from "@/api"

const state ={
  detailInfo: {}
}

const mutations = {
  SET_DETAILINFO_STATE(state,value){
    state.detailInfo = value
  }
}

const actions = {
  async getDetailInfo({commit}, skuId){
    const res = await reqDetailInfo(skuId)
    commit('SET_DETAILINFO_STATE',res)
  }
}


const getters = {
    //
    categoryView(state) {
      return state.detailInfo.categoryView || {};
    },
    //
    spuSaleAttrList(state) {
      return state.detailInfo.spuSaleAttrList || [];
    },
    //
    skuInfo(state) {
      return state.detailInfo.skuInfo || {};
    },
    skuImageList(state) {
      return state.detailInfo.skuInfo.skuImageList || [];
    },
}

export default {
  state,
  mutations,
  actions,
  getters,
  namespaced:true,
}